from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession

from app.crud.base import CRUDBase
from app.models.patient_profile import PatientProfile
from app.schemas.user import PatientProfileCreate


class CRUDPatientProfile(CRUDBase[PatientProfile, PatientProfileCreate, PatientProfileCreate]):
    async def get_by_user_id(self, db: AsyncSession, *, user_id: str):
        result = await db.execute(select(PatientProfile).filter(PatientProfile.user_id == user_id))
        return result.scalars().first()


patient_profile = CRUDPatientProfile(PatientProfile)
